package com.zed.api.games.answer.action;

import com.zed.api.common.param.DefaultParamsConfig;
import com.zed.api.games.Action;
import com.zed.api.games.GameException;

import java.io.Serial;
import java.util.List;
import java.util.Map;

/**
 * 答题动作
 *
 * @author Zed
 */
public abstract class AnswerAction extends DefaultParamsConfig implements Action {

    @Serial
    private static final long serialVersionUID = 4752277743824874126L;

    protected AnswerAction() {

    }

    protected AnswerAction(Map<String, Object> params) {
        super(params);
    }

    /**
     * 校对必填参数部位空
     */
    public void verifyMustFillParameters() throws GameException {
        List<String> mustFillParameters = this.getMustFillParameters();
        if (mustFillParameters == null || mustFillParameters.isEmpty()) return;

        for (String mustFillParameter : mustFillParameters) {
            Object parameter = this.getParameter(mustFillParameter);
            if (parameter == null) {
                throw new GameException("没有正确填写相关参数,请选择对应的参数");
            }
        }

    }


}
